﻿using System.ComponentModel.Composition;
using GalaSoft.MvvmLight.Messaging;

namespace MapInfo.Toolbox.Core
{
    /// <summary>
    /// A module that can run by the MapInfo.Toolbox project, inherit from this class to get MapInfo.Toolbox UI to load it.
    /// <parm>Module must have a empty constructor or MapInfo.Toolbox will not be able to create the instance of the module.</parm>
    /// </summary>
    [InheritedExport(typeof(IToolboxModule))]
    public interface IToolboxModule
    {
        /// <summary>
        /// The name of the module.
        /// </summary>
        string Name { get; set; }
        
        /// <summary>
        /// The description of what the module does.
        /// </summary>
        string Description { get; set; }

        /// <summary>
        /// The current version of this module.
        /// </summary>
        int Version { get; set; }

        /// <summary>
        /// Gets the messager that can be used to send messages to the UI.
        /// Do not use this property direclty instead use RaiseUpdateStatus update the UI.
        /// </summary>
        [Import(typeof(IMessenger))]
        IMessenger Messager { get; set; }

        /// <summary>
        /// This method will be called when the item is selected by the user.
        /// Any code that the module runs must start from here.
        /// </summary>
        void Run();

        /// <summary>
        /// Raises the event to update the UI with the status of the running module.
        /// </summary>
        /// <param name="message"></param>
        void UpdateStatus(string message);
    }
}
